import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import user from './modules/user'
import home from './modules/home';
import audit from './modules/audit'
import search from './modules/search'
import searchNotice from './modules/searchNotice';
import others from "@/store/modules/others";


Vue.use(Vuex)

const store = new Vuex.Store({
  // 每一个页面模块
  modules: {
    home,
    user,
    audit,
    search,
    searchNotice,
    others,
  },
  state:{
    msg:{},
    chatUserList:[],
    messageList:[]
  },
  getters,
  actions:{
    setRecords({commit,state}, name){

      commit("setMsg", name);
    },
    // 获取在线消息列表
    setChatUserList({commit,state}, users){
      commit("setUsers", users);
    },
    // 获取聊天记录
    setMessage({commit,state}, message){
      commit("setMessageList", message);
    },
  },
  mutations:{
    setMsg(state, name){
      state.msg = name;
    },
    setUsers(state, users){
      state.chatUserList = users;
    },
    setMessageList(state, message){
      state.messageList = message;
    },
  }
})

export default store
